<template lang="html">
  <el-table :data="this.$store.getters.mylist.tableList" style="width: 100%">
    <el-table-column label="收款单位" prop="sup.suppliername">
    </el-table-column>
    <el-table-column label="出纳人" prop="payBy">
    </el-table-column>
    <el-table-column label="支出事由" prop="payReason">
    </el-table-column>
    <el-table-column label="支出金额" prop="price">
    </el-table-column>
    <el-table-column label="支出时间" prop="time">
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button-group>
          <el-button @click="handleDelete(scope.$index, scope.row)" type="danger" size="mini" icon="el-icon-delete" v-if="!scope.row.goods_units_name"></el-button>
          <el-button @click="handleDelete(scope.$index, scope.row)" type="danger" size="mini" icon="el-icon-delete" v-if="scope.row.goods_units_name" disabled></el-button>
        </el-button-group>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { mapActions } from 'vuex'
import * as url from '../../../api/ygrapi.js'
export default {
  name: 'Ctable',
  components: {

  },
  data() {
    return {

    }
  },
  methods: {
     ...mapActions(['getTable','expend/getLists','expend/opList']),
    handleDelete(index, row) {
      console.log(index, row)
      this.$confirm(`是否删除支出时间为${row.time}?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this['expend/opList']([url.delCBData,{time:row.time}]).then(res=>{
              return this.$store.commit('expend/message',{res:res,tt:this})
            }).catch(err=>{
              console.log(err)
            }).then(res=>{
              this['expend/getLists']([url.getCBData])
            })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
  },
  created() {

  },
}

</script>
<style lang="less">
</style>
